package com.technologys.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.technologys.dao.UserDao;
import com.technologys.pojo.UserPojo;

@Repository(UserDao.BEAN_NAME)
public class UserDaoImpl implements UserDao {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	public UserDaoImpl() {
	}
	
	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	@Override
	public UserPojo queryUserByUserid(String userid) {
		return this.sqlSessionTemplate.selectOne("user.queryUserByUserid", userid);
	}

	@Override
	public List<String> queryRolesByUserid(String userid) {
		return this.sqlSessionTemplate.selectList("user.queryRolesByUserid", userid);
	}

	@Override
	public List<String> queryPermissionsByRoleid(String roleid) {
		return this.sqlSessionTemplate.selectList("user.queryPermissionsByRoleid", roleid);
	}
}